package chat01;

import java.util.ArrayList;

public class Day10text {
    public static void main(String[] args) {
        ArrayList<Day10> arrayList = new ArrayList<>();
        Day10 day0 = new Day10();//第一个学生信息
        Day10 day1 = new Day10();//第二个学生信息
        Day10 day2 = new Day10();//第三个学生信息
        day0.setName("张三");
        day0.setId(1);
        day1.setName("李四");
        day1.setId(2);
        day2.setName("王五");
        day2.setId(3);
        arrayList.add(day0);
        arrayList.add(day1);
        arrayList.add(day2);
        System.out.println("初始学生列表:");
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }//0,1,2代表着集合的下标
        for (int i = 0; i < arrayList.size(); i++) {
            if (arrayList.get(i).getName().equals("张三")){
                arrayList.get(i).setName("张三丰");
                System.out.println(arrayList);
            }
        }//arrayList.fori
        for (int i = 0; i < arrayList.size(); i++) {
            if (arrayList.get(i).getName().equals("王五")){
                arrayList.remove(i);
                System.out.println(arrayList);
            }
        }
    }
}
